//
//  AuthenticationTableViewCell.m
//  chongwu
//
//  Created by 隼目 on 2021/9/23.
//

#import "AuthenticationTableViewCell.h"

@implementation AuthenticationTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)creatView{
    self.backgroundColor=[UIColor clearColor];
    
    UIView *backView=[UIView new];
    [self.contentView addSubview:backView];
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30*_mainHeight);
        make.right.mas_equalTo(-30*_mainWidth);
        make.top.mas_equalTo(20*_mainHeight);
        make.bottom.mas_equalTo(-20*_mainHeight);
    }];
    backView.backgroundColor=[UIColor whiteColor];
    backView.layer.cornerRadius=25*_mainWidth;
    backView.layer.shadowColor = rgba(74,31,0,0.1).CGColor;
    backView.layer.shadowOffset = CGSizeMake(0,0);
    backView.layer.shadowOpacity = 1;
    backView.layer.shadowRadius = 2;
    
    
    UIImageView *image=[UIImageView new];
    [backView addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(39*_mainWidth);
        make.top.mas_equalTo(52*_mainHeight);
        make.width.mas_equalTo(52*_mainWidth);
        make.height.mas_equalTo(38*_mainWidth);
    }];
    image.image=[UIImage imageNamed:@"shenfenzheng"];
    
    UILabel *label=[UILabel new];
    [backView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(image.mas_right).mas_equalTo(23*_mainWidth);
        make.centerY.mas_equalTo(image);
    }];
    label.text=@"身份证";
    label.font=[UIFont fontWithName:@"PingFang SC" size:autoScaleW(36)];
    label.textColor=rgba(47,47,47,1);
    
    
    UILabel *label2=[UILabel new];
    [backView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(image);
        make.top.mas_equalTo(123*_mainHeight);
        make.right.mas_equalTo(-220*_mainWidth);
    }];
    label2.numberOfLines=0;
    label2.text=@"年龄需18周岁至60周岁之间";
    label2.font=[UIFont fontWithName:@"PingFang SC" size:autoScaleW(28)];
    label2.textColor=rgba(102,102,102,1);
    
    UIButton *btn=[UIButton new];
    [backView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-52*_mainWidth);
        make.width.mas_equalTo(148*_mainWidth);
        make.height.mas_equalTo(60*_mainHeight);
    }];
    btn.layer.masksToBounds=YES;
    btn.layer.cornerRadius=10*_mainHeight;
    btn.layer.borderWidth=1.5;
    [btn setTitle:@"去拍摄" forState:0];
    btn.titleLabel.font=[UIFont fontWithName:@"PingFang SC" size:autoScaleW(26)];
    if (self.IDImage==nil) {
        btn.enabled=YES;
        btn.layer.borderColor=rgba(255,102,0,1).CGColor;
        [btn setTitleColor:rgba(255,102,0,1) forState:0];
    }else{
        btn.enabled=NO;
        btn.layer.borderColor=rgba(157,157,157,1).CGColor;
        [btn setTitleColor:rgba(157,157,157,1) forState:0];
    }
    [btn addTarget:self action:@selector(selectSelectPictureBtn) forControlEvents:UIControlEventTouchUpInside];
}
-(void)creatBtnView{
    self.backgroundColor=[UIColor clearColor];
    
    UIButton *signInBtn=[UIButton new];
    [self.contentView addSubview:signInBtn];
    [signInBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(39*_mainWidth);
        make.width.mas_equalTo(_mainW-78*_mainWidth);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(_mainHeight*87);
    }];
    [signInBtn setTitle:@"提交" forState:0];
    [signInBtn setTitleColor:[UIColor whiteColor] forState:0];
    signInBtn.titleLabel.font=[UIFont fontWithName:@"PingFang SC" size:autoScaleW(36)];
    [signInBtn layoutIfNeeded];
    signInBtn.layer.masksToBounds=YES;
    signInBtn.layer.cornerRadius=87*_mainHeight/2;
    
    if (self.IDImage==nil) {
//        signInBtn.enabled=NO;
        signInBtn.backgroundColor=rgba(157, 157, 157, 1);
    }else{
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.frame = signInBtn.bounds;
        //将CAGradientlayer对象添加在我们要设置背景色的视图的layer层
        [signInBtn.layer insertSublayer:gradientLayer atIndex:0];
        //设置渐变区域的起始和终止位置（范围为0-1）
        gradientLayer.startPoint = CGPointMake(0, 1);
        gradientLayer.endPoint = CGPointMake(1, 1);
        gradientLayer.colors = @[(__bridge id)rgba(255,159,0,1).CGColor,
                                 (__bridge id)rgba(255,116,0,1).CGColor ,
                                 (__bridge id)rgba(255,102,0,1).CGColor];
        //设置颜色分割点（范围：0-1）
        gradientLayer.locations = @[@(0),@(0.5), @(1.0f)];
        signInBtn.layer.shadowColor = rgba(196,50,0,0.36).CGColor;
        signInBtn.layer.shadowOffset = CGSizeMake(0,0);
        signInBtn.layer.shadowOpacity = 1;
        signInBtn.layer.shadowRadius = 4;
    }
    [signInBtn addTarget:self action:@selector(pushToController:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)selectSelectPictureBtn{
    if (self.delegate!=nil) {
        [self.delegate selectSelectPicture];
    }
}
-(void)pushToController:(UIButton *)btn{
    if (self.delegate!=nil) {
        [self.delegate pushToController];
    }
}
@end
